<%--
  Created by IntelliJ IDEA.
  User: zjsxx
  Date: 2018/1/25
  Time: 15:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/form_validate.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:15 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>EasyLink 新用户注册</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">


    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet">


</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-1"></div>
        <div class="col-sm-10">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>新增动作 </h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="deviceForm">
                        <%--设备名--%>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">动作名：</label>
                            <div class="col-sm-8">
                                <input id="actionName" name="actionName" class="form-control" type="text">
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 为您的新动作取一个名字</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">消息内容：</label>
                            <div class="col-sm-8">
                                <textarea id="actionDesc" name="desc" class="form-control" rows="3"
                                          cols="20"></textarea>
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里的内容将会通过您选择的形式，发送出去，请注意言论文明合法</span>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">类型：</label>
                                <div class="col-sm-9">
                                    <select id="actionType" class="form-control" name="">
                                        <option value="1">邮件</option>
                                        <option value="2">短信</option>
                                    </select>
                                </div>
                            </div>
                        </div>


                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button id="subBtn" class="btn btn-primary" type="button">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="col-sm-1"></div>
    </div>
</div>
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/content.min.js?v=1.0.0"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>
<script src="/js/demo/form-validate-device.min.js"></script>
<script src="/js/jquery.json.js"></script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script src="/js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(document).ready(function () {
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return decodeURI(r[2]);
            return null; //返回参数值
        }
        var key = null;
        var v = document.cookie.split(";");
        for (var i = 0; i < v.length; i++) {
            var item = v[i].split("=");
            if (item[0] == 'easylink_user_token') {
                key = item[1];
                break;
            }
        }

        $('#subBtn').click(function () {
            var actionName = $('#actionName').val();
            var actionDesc = $('#actionDesc').val();
            var actionType = $('#actionType').val();
            $.ajax({
                type: 'POST',
                headers: {
                    'easylink_user_token': key
                },
                url: '/action/insertAction',
                dataType: 'json',
                contentType: "application/json; charset=utf-8",
                data: $.toJSON({
                    "actionName": actionName,
                    "actionDesc": actionDesc,
                    "actionType": actionType
                }),
                success: function (message) {
                    if(message.status == 200){
                        alert('新增动作成功');
                        $(location).attr('href', '/userManager/actionList');
                    }else{
                        alert(message.msg);
                    }

                },
                error: function (message) {
                    console.log(message);
                    alert(message.data);
                }
            });
        });
    });
</script>
</body>
</html>
